home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / objcissu.lha / instance-archiving < prev    next >
Internet Message Format  |  1993-02-27  |  2KB

  1. From: Kevin A. Sapp <sapp%sawdust@sawdust.ssc.gov>
  2. Subject: Objective-C Source
  3. To: gsk@marble.com
  4. Date: Wed, 20 Jan 93 16:29:03 CST
  5. Mailer: Elm [revision: 66.25]
  6.  
  7.  
  8. Geoffrey,
  9.  
  10. I have some source for what I call "instance archiving".  It is really 
  11. a random access, variable record length, with recycling file.  It works
  12. in much the same way that NeXT's archiving does with  -write and -read
  13. methods (but does not contain the ENTIRE CLASS info).
  14.  
  15. At this point the code can store variable sized objects along with their
  16. class and some other stuff.  When I get some time I am going to create
  17. a - readAndCreateAtRecordNumber: method which would first read the class
  18. perform an alloc and then call the objects -read/writes (I think I called
  19. them readIt and writeIt [WOW]).  It is not fully tested or fully featured.
  20.  
  21. A sample read is:
  22.  
  23. @interface Stuff:Object
  24. {
  25.         int             anInt;
  26.         float   aFloat;
  27.         double  aDouble;
  28. }
  29. ...
  30.  
  31. - (BOOL)readIt:stream
  32. {
  33.         [stream readInt:&anInt];                //this is a BOOL not checked
  34.         [stream readFloat:&aFloat];             //this is a BOOL not checked
  35.         [stream readDouble:&aDouble];           //this is a BOOL not checked
  36.         return YES;
  37. }
  38.  
  39. support is provided for 8,16,32 bit integers, 32 and 64 bit floats,
  40. char strings and mem buffers(I think).
  41.  
  42. I have also performed some work on my own encoding and decoding of structures
  43. and classes.  The code uses an encode string (ala NeXT, does GNU support 
  44. this ?, THEY SHOULD!!!), parses it and puts it in a KNOWN format. 
  45.  
  46. Wouldn't it be nice to say [stream writeObject:anObject at:recordNumber] 
  47. and the object supports an -encodeString method that could be queried so
  48. that NO -read or -write methods have to be written?  and is portable to 
  49. any processor (big or little endian, different structure packing...)
  50.  
  51. The code is available, just let me know.
  52. (214)708-3345
  53.  
  54. --
  55. ----------------------------------------------------------------------------
  56. Kevin A. Sapp                    "A civilization depends upon the quality
  57. Superconducting Super Collider    of individual it creates"   (Dune)
  58. sapp@sawdust.ssc.gov :>( please NO NeXT mail                   
  59.  
  60.  
  61.